/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package struts;

import Service.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 *
 * @author jo
 */
public class LoginAction extends Action{

    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {

        LoginActionForm laf = null;
        if(form!=null){
            laf = (LoginActionForm)form;
        }else
        System.out.println("no form");

        String email = laf.getEmail();
        String password = laf.getPassword();

        MemberService ms= new MemberServiceImpl();

        if(0==ms.login(email, password))
        {
            request.setAttribute("userid", email);
            return mapping.findForward("success");
        }else
        {
            return mapping.findForward("failed");
        }
        // return super.execute(mapping, form, request, response);
    }
}
